#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<unordered_map>
using namespace std;

unordered_map<string, int> h;

int main() {
	int n; cin >> n;
	while (n--) {
		int c;
		string str;
		cin >> c >> str;
		if (c == 1) h[str]++;
		else {
			if (h.count(str)) cout << h[str] << endl;
			else cout << "No" << endl;
		}
	}
	return 0;
}